import {Component, OnDestroy, OnInit} from '@angular/core';
import {PermissionType} from "../../constants/constants";
import {Router} from "@angular/router";
import {PortalsService} from "../portals.service";

declare var $;

@Component({
  selector: 'app-big-screen',
  templateUrl: './big-screen.component.html',
  styleUrls: ['./big-screen.component.css']
})
export class BigScreenComponent implements OnInit, OnDestroy {


  constructor(
    private portalsService : PortalsService,
    private router: Router,
  ) { }

  ngOnInit() {
    this.loadData();
  }
  ngOnDestroy() {
    $('.control-sidebar').removeClass('control-sidebar-open');
    $('body').removeClass('control-sidebar-open');
  }
  private loadData(){
    this.getMenus();
  }

  private getMenus(){
    this.portalsService.getPermissions(PermissionType.menus)
      .subscribe(
        data => this.generateMenusDom(data),
        error => this.show(error)
      );
  }
  private generateMenusDom(data:any){
    // console.log(data);
  }
  private show(message:string){
    // console.log(message);
  }
  onActivate(){
    if(this.router.url.indexOf('admin') != -1){
      $(".one-dv-header-btn").hide();
      $('.content-header').show();
    }else{
      $(".one-dv-header-btn").show();
      $('.content-header').hide();
    }
  }

}
